package top.laoliu.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.laoliu.mapper.CompanyMapper;
import top.laoliu.pojo.ApplyInfo;
import top.laoliu.pojo.Company;
import top.laoliu.pojo.CompanyInfo;
import top.laoliu.service.CompanyService;

import java.util.List;

/**
 * @Author: acer
 * @Date: 2020/10/15 22:49
 * @Description:
 */
@Service
public class CompanyServiceImpl implements CompanyService {
    @Autowired
    private CompanyMapper companyMapper;

    @Override
    public int insertCompany(Company company) {
        return companyMapper.insertCompany(company);
    }

    @Override
    public int deleteCompany(Integer company_id) {
        return companyMapper.deleteCompany(company_id);
    }

    @Override
    public Company getCompanyById(Integer company_id) {
        return companyMapper.getCompanyById(company_id);
    }

    @Override
    public Company getCompanyByEmail(String email) {
        return companyMapper.getCompanyByEmail(email);
    }

    @Override
    public boolean isExistCompany(String email, String phone) {
        Company companyByEmail = companyMapper.getCompanyByEmail(email);
        Company companyByPhone = companyMapper.getCompanyByPhone(phone);
        if (companyByEmail == null && companyByPhone == null) {
            return false;
        }
        return true;
    }

    @Override
    public boolean companyLogin(String email, String password) {
        Company company = companyMapper.companyLogin(email, password);
        if (company==null){
            return false;
        }
        return true;
    }

    @Override
    public int updateCompany(Company company) {
        return companyMapper.updateCompany(company);
    }

    @Override
    public List<ApplyInfo> getApplyInfoByCompany_id(Integer company_id) {
        return companyMapper.getApplyInfoByCompany_id(company_id);
    }

    @Override
    public int insertCompanyInfo(CompanyInfo companyInfo) {
        return companyMapper.insertCompanyInfo(companyInfo);
    }

    @Override
    public int updateCompanyInfo(CompanyInfo companyInfo) {
        return companyMapper.updateCompanyInfo(companyInfo);
    }

    @Override
    public CompanyInfo getCompanyInfo(Integer info_id) {
        return companyMapper.getCompanyInfo(info_id);
    }
}
